<div class="content-section introduction">
    <div>
        <span class="feature-title">InputSwitch</span>
        <span>InputSwitch is used to select a boolean value.</span>
    </div>
</div>

<div class="content-section implementation">
    <h3 class="first">Basic - {{checked1}}</h3>
    <p-inputSwitch [(ngModel)]="checked1"></p-inputSwitch>

    <h3>Labels - {{checked2}}</h3>
    <p-inputSwitch onLabel="Yes" offLabel="No" [(ngModel)]="checked2"></p-inputSwitch>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;InputSwitchModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Two-way binding to a boolean property is defined using the standard ngModel directive.</p>

<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputSwitch [(ngModel)]="checked"&gt;&lt;/p-inputSwitch&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    checked: boolean;

&#125;
</code>
</pre>

            <p>As model is two-way binding enabled, setting the bound value as true displays the state as checked by default.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

   checked: boolean = true;

&#125;
</code>
</pre>

            <h3>Model Driven Forms</h3>
            <p>InputSwitch can be used in a model driven form as well.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputSwitch formControlName="enabled"&gt;&lt;/p-inputSwitch&gt;
</code>
</pre>

            <h3>Customization</h3>
            <p>Labels can be customized using onLabel and offLabel properties.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputSwitch onLabel="I confirm" offLabel="I reject" [(ngModel)]="val"&gt;&lt;/p-inputSwitch&gt;
</code>
</pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onLabel</td>
                            <td>string</td>
                            <td>On</td>
                            <td>Label for the on state.</td>
                        </tr>
                        <tr>
                            <td>offLabel</td>
                            <td>string</td>
                            <td>Off</td>
                            <td>Label for the off state.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                          <td>tabindex</td>
                          <td>number</td>
                          <td>null</td>
                          <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>ariaLabelTemplate</td>
                            <td>string</td>
                            <td>InputSwitch &#123;0&#125;</td>
                            <td>The aria-label template is used to define a string that labels the current element with a template.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Parameters</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>onChange</td>
                        <td>event.originalEvent: browser event<br>
                            event.checked: checked state as a boolean</td>
                        <td>Callback to invoke on state change.</td>
                    </tr>
                    </tbody>
                </table>
            </div>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputSwitch (onChange)="handleChange($event)" [(ngModel)]="val"&gt;
</code>
</pre>
 <pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    handleChange(e) &#123;
        var isChecked = e.checked;
    &#125;
&#125;
</code>
</pre>

            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-inputswitch</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>ui-inputswitch-on</td>
                            <td>Checked state element.</td>
                        </tr>
                        <tr>
                            <td>ui-inputswitch-off</td>
                            <td>Unchecked state element.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/inputswitch" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;h3 class="first"&gt;Basic - {{checked1}}&lt;/h3&gt;
&lt;p-inputSwitch [(ngModel)]="checked1"&gt;&lt;/p-inputSwitch&gt;

&lt;h3&gt;Labels - &lt;span&gt; {{checked2}}&lt;/h3&gt;
&lt;p-inputSwitch onLabel="Yes" offLabel="No" [(ngModel)]="checked2"&gt;&lt;/p-inputSwitch&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class InputSwitchDemo &#123;

    checked1: boolean = false;

    checked2: boolean = true;
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>
